#!/bin/bash
#Author:jinxingvenus.msn.com
#Date:20160102
#Update:20161117
#Purpose:delete staging demo log

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Cur_Dir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
(( $EUID != 0 )) && {
    echo "ERROR: You must be root to run this script."
    exit 1
}
Cur_Time="$(date +%Y%m%d%H%M%S)"

echo "1. 开始清理/usr/local/applogs/下的日志..."
for m in `find /usr/local/applogs/ -type f -size +10M`;
do
        echo "正在清理文件: $m";
        echo >$m;
done
echo "2. 开始清理/usr/local/app/下的日志..."
for i in `find /usr/local/app -name 'catalina.out' `;
do
        echo "正在清理文件: $i";
        echo >$i ;
done

echo "3. 开始清理/usr/local/logs/beetle-agent/下的日志..."
for i in `find /usr/local/logs/beetle-agent -name '*.log' `;
do
        echo "正在清理文件: $i";
        echo >$i ;
done

echo "4. 开始清理/tmp/logs/下的日志..."
for j in `find /tmp/logs/ -name '*.log' -type f`
do
        File_Size="$(ls -lt $j|awk '{print $5}')"
        if [ ${File_Size} -gt 500000000 ];then
                echo  ${File_Size} $j
                echo > $j
        fi
done
#echo "开始清理winit-dep-web的日志..."
#find /usr/local/ -name 'wint-dep-web*' |xargs rm -f {} \;
echo "5. 开始清理/usr/local/applogs/下过期的日志..."
find /usr/local/applogs/ -type f -mtime +2 |xargs rm -f {} \;
unset i
unset j
unset m
unset k